package com.leyou.item.servcie.impl;

import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.leyou.item.entity.Sku;
import com.leyou.item.entity.Spu;
import com.leyou.item.mapper.SkuMapper;
import com.leyou.item.mapper.SpuMapper;
import com.leyou.item.servcie.SkuService;
import com.leyou.pojo.dto.SkuDto;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements SkuService {
    @Override
    public List<SkuDto> querySkuBySpuId(Long spuId) {
        List<Sku> skuList = query().eq("spu_id", spuId).list();
        List<SkuDto> skuDtoList = skuList.stream().map(SkuDto::new).collect(Collectors.toList());
        return skuDtoList;
    }
}
